import axios from '../request'

// 添加文章
const addArticleApi = (data: Object) => axios.post('/manage/article/add', data)

// 修改文章
const upArticleApi = (data: Object) => axios.post('/manage/article/update', data)

// 获取所有文章
const getArticleApi = (data?: Object) => {
  if (data) {
    return axios.get('/manage/article/find', { params: data })
  } else {
    return axios.get('/manage/article/find')
  }
}

// 搜索文章
const searchArticleApi = (data: Object) => axios.post('/manage/article/search', data)

// 搜索一种文章
const searchArticleOneApi = (data: Object) => axios.get('/manage/article/search/one', { params: data })

// 搜索文章
const gainArticleApi = (data: Object) => axios.post('/manage/article/gain', data)

// 删除文章
const delArticleApi = (data: Object) => axios.post('/manage/article/del', data)

// 发布文章
const releaseArticleApi = (data: Object) => axios.post('/manage/article/release', data)

// 获取文章总数
const getArticleNumApi = (data?: Object) => axios.get('/manage/article/total', { params: data })

// 获取文章查看数
const articleLookApi = (data: Object) => axios.post('/manage/article/look', data)

// 点赞文章总数
const articleDiscussApi = (data: Object) => axios.post('/manage/article/discuss', data)

export {
  addArticleApi,
  getArticleApi,
  searchArticleApi,
  delArticleApi,
  upArticleApi,
  releaseArticleApi,
  getArticleNumApi,
  gainArticleApi,
  articleLookApi,
  articleDiscussApi,
  searchArticleOneApi
}